#include <bits/stdc++.h>
using namespace std;
#ifdef W_DEBUG
#define DOUT(a) cerr << __FILE__ << ':' << __LINE__ << ":D:" << a << endl
#else
#define DOUT(a) void(0)
#endif
using ll = long long;

namespace s1
{
    void Main()
    {
	ll n, m, l, v;
	cin >> n >> m >> l >> v;
	vector<ll> d(n);
	auto u = d, a = d;
	bool f1 = true, f3 = true;
	for (ll i = 0; i < n; ++i)
	{
	    cin >> d[i] >> u[i] >> a[i];
	    f1 &= (a[i] >= 0);
	    f3 &= (a[i] < 0);
	}
	vector<ll> p(m);
	for(auto& i : p)
	{
	    cin >> i;
	}
	if (f1)
	{
	    ll ans = 0;
	    for (ll i = 0; i < n; ++i)
	    {
		if (d[i] <= p.back() and u[i] * u[i] + 2 * a[i] * (p.back() - d[i]) >= v * v)
		{
		    ++ans;
		}
	    }
	    cout << ans << ' ' << m - 1 << endl;
	}
	
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#define W_NAME "detect"
    freopen(W_NAME ".in", "r", stdin);
    freopen(W_NAME ".out", "w", stdout);
    ll t;
    cin >> t;
    DOUT(t);
    
    while(t--)
    {
	s1::Main();
    }
    
    return 0;
}
